﻿namespace Nintest.Model
{
    using System;

    public static class EventHandlerExtensions
    {
        public static void SafeInvoke<T>(this EventHandler<T> eventHandler, object sender, T args)
            where T : EventArgs
        {
            if (eventHandler == null)
                return;
            eventHandler.Invoke(sender, args);
        }

        public static void SafeInvoke(this EventHandler eventHandler, object sender)
        {
            if (eventHandler == null)
                return;
            eventHandler.Invoke(sender, EventArgs.Empty);
        }
    }
}